package lesson2.api;

import java.util.concurrent.TimeUnit;

import lesson2.api.helpers.NavigationHelper;
import lesson2.api.helpers.PageHelper;
import lesson2.api.helpers.WebElementHelper;

import org.openqa.selenium.firefox.FirefoxDriver;

public class ApplicationManager
{
	public FirefoxDriver driver;
	private PageHelper pageHelper;
	private NavigationHelper navigationHelper;
	private WebElementHelper webElementHelper;
	public String siteUrl = "https://redmine.cupidplc.com";

	public ApplicationManager()
	{

	}

	public void init()
	{
		// Create a driver
		driver = new FirefoxDriver();
		driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
		navigationHelper().openPage("/");
	}

	public void stop()
	{
		// Stop a driver
		driver.quit();
	}

	public PageHelper pageHelper()
	{
		if (pageHelper == null)
		{
			pageHelper = new PageHelper(this);
		}
		return pageHelper;
	}

	public NavigationHelper navigationHelper()
	{
		if (navigationHelper == null)
		{
			navigationHelper = new NavigationHelper(this);
		}
		return navigationHelper;
	}

	public WebElementHelper webElementHelper()
	{
		if (webElementHelper == null)
		{
			webElementHelper = new WebElementHelper(this);
		}
		return webElementHelper;
	}

}
